<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" type="text/css" href="../../css/style.css" />
		<link rel="stylesheet" type="text/css" href="../../css/demo.css" />
		<script src="../../js/demo.js" type="text/javascript" charset="utf-8"></script>
		<title>佣金提现</title>
	</head>
	<body>
		<!--header-->
		<div class="header">
			<div class="header-content">
				<ul class="nav left">
					<li><img src="../../img/regist-arrow.png" /></li>
					<li class="nav-one">
						<a href="javascript:history.go(-1);">返回</a>
					</li>
					<li class="nav-two">
						<a href="../../">关闭</a>
					</li>
				</ul>
				<p class="left">佣金提现</p>
				<div class="right nav_right">
					<img src="../../img/regist-list.png" />
				</div>
			</div>
		</div>
		<!--main-->
		<div class="main clear">
		
		</div>
		<script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
		<script type="text/javascript">
			selectCommissionGetMessage();
			//查询用户商铺佣金信息
			function selectCommissionGetMessage(){
				$.ajax({
					type:"post",
					url:"/qiaomengapp/commission/api/selectCommissionGetMessage",
					success:function (data){
						if(data.error!=undefined){
							alert(data.error);							
						}else{
							//清空原先显示内容
							$(".main").html("");
							//可用佣金
							var able_commission = data.able_commission.toFixed(2);
							//银行卡尾号
							var cardCodeStr = data.card.cardCode+"";
							var endCardCode = cardCodeStr.substr((cardCodeStr.length-4),4);
							
						   $(".main").append("<div class='self-commision'>"+
									"<ul class='commisionlist'>"+
									"<li class='commisionlist-one left'><img src='../../img/self-commission3.png'/></li>"+
									"<li class='commisionlist-two left'>账户余额(元)</li>"+
									"<li class='commisionlist-thr right'>明细<img src='../../img/self-commission2.png' alt='' /></li>"+
								"</ul>"+
								"<ul class='commisionlist2'>"+
									"<li class='commisionlist2-one left' ableCommission >"+able_commission+"</li>"+
									"<li class='commisionlist2-two right'> <img src='../../img/self-commission.png'/></li>"+
								"</ul>"+
							"</div>"+
							"<div class='self-commisioncard'>"+
								"<ul class='self-commisioncardlist'>"+
									"<li class='commisioncardlist-one left'><img src='../../img/self-commission4.png'/></li>"+
									"<li class='commisioncardlist-two left'>"+data.card.bankName+"<br /><span>尾号"+endCardCode+"</span></li>"+
									"<li class='commisioncardlist-thr right'><img src='../../img/interface-icon2.png'/></li>"+
								"</ul>"+
							"</div>"+
							"<div class='self-commisioncard2'>"+
								"<div class='self-commisioncardlist2'>"+
									"注：金额需大于100元才可提现。"+
								"</div>"+
							"</div>"+
							"<div class='self-cash'>"+		
								"<div class='selfcash'>"+
									"<label for='selfcash' style='font-size: 0.24rem;color: #595757;'>"+
										"提现金额"+ 
									"</label>"+
									 "<input cardCode='"+cardCodeStr+"' shopId='"+data.shopWarp.id+"' type='text' id='' value='' name='selfcash' placeholder='请输入提现金额'/>"+
								     "<a href='javascript:void(-1);' onclick='withdrawAllCommission()'>全额提出</a>"+
								"</div>"+
							"</div>"+
							   "<input type='button' onclick='withdrawCommission()'  id='' value='申请提现' class='apply-cash'/>"); 
						}
					}
				});
			}
			
			//用户进行提现操作
			function withdrawCommission(){
				var cardCode = $("[cardCode]").attr("cardCode");
				var shopId = $("[shopId]").attr("shopId");
				var money = $("input[name='selfcash']").val();
				//使用restful风格进行请求
				$.ajax({
					type:"phone",
					url:"/qiaomengapp/commission/api/updateGetCommission/"+shopId+"/"+money+"/"+cardCode,
					success:function(data){
						if(data.error!=undefined){
							alert(data.error);
						}else{
							alert(data.success);
							//重新显示页面
							selectCommissionGetMessage();
						}
					}
				});
			}
			
			//用户进行全额提现
			function withdrawAllCommission(){
				var ableCommission = $("li[ableCommission]").html();
				$("input[name='selfcash']").val(ableCommission);
			}
		</script>
	</body>
</html>